using System.Data;
using System.Data.OleDb;

public class ConexionBD{

  private OleDbConnection conn;

  public ConexionBD(string dbName, string userName, string password)
  {
    conn = new OleDbConnection(
              "Provider=SQLNCLI;Server=localhost;Database=" + dbName
              + ";Uid=" + userName + "; Pwd=" + password + ";");
  }

  //Debe colocarse dentro de try/catch (puede arrojar OleDbException)
  public void executeDataQuery(string query)
  {
    OleDbCommand com = new OleDbCommand(query, conn);

    conn.Open();
    com.ExecuteNonQuery();
    conn.Close();
  }

  //Debe colocarse dentro de try/catch (puede arrojar OleDbException)
  public DataSet executeDataSet(string selectQuery)
  {
    OleDbCommand com = new OleDbCommand(selectQuery, conn);
    DataSet ds = new DataSet();
    OleDbDataAdapter data = new OleDbDataAdapter(com.CommandText, conn);
    data.Fill(ds);

    return ds;
  }
}
